package com.yimi.policyservice.repository;

import com.yimi.policyservice.entity.base.policy.PolicyComminsureProduct;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface PolicyComminsureProductRepository extends JpaRepository<PolicyComminsureProduct,String> {
    @Modifying
    @Transactional
    @Query(value = "delete from t_policy_comminsure_product where id in ?1",nativeQuery = true)
    void deleteByIdIn(List<String> ids);
    @Query(value = "select * from t_policy_comminsure_product where optr_comp_id in (select data_value from " +
            "t_sys_user_data_permission where user_id =?1)",nativeQuery = true)
    List<PolicyComminsureProduct>findAllByPermission(String userId);

    PolicyComminsureProduct findFirstByProductCode(String productCode);
}
